//
//  VideoViewController.m
//  A_HandHeldLOL
//
//  Created by Zhao YanBin on 16/1/16.
//  Copyright © 2016年 zhaoyanbin. All rights reserved.
//

#import "VideoViewController.h"
#import "VideoCollectionViewCell.h"
#import "VideoXiangqingViewController.h"
#import <UIImageView+WebCache.h>
#import "AFNModel.h"
#import "ShiPinModel.h"
@interface VideoViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property(nonatomic, retain)UICollectionView *fenleicolltion;

@property(nonatomic, retain)NSArray *dataArr;
@property(nonatomic, retain)NSArray *arr;
@property(nonatomic, retain)NSArray *shipinxqArr;
@property(nonatomic, retain)NSArray *webArr;

@property(nonatomic, retain)NSMutableArray *shipinArr;
@end

@implementation VideoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"视频";
    
    
//    //webView  铺设
//    UIWebView *wv = [[UIWebView alloc] initWithFrame:self.view.bounds];
////    wv.backgroundColor = [UIColor magentaColor];
//    [self.view addSubview:wv];
//    NSString *url = @"http://lol.qq.com/m/act/a20150319lolapp/video.htm?APP_BROWSER_VERSION_CODE=1&ios_version=801";
//    [wv loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self creatcollectionV];
    
    [self shipin];
    
    
}

-(void)creatcollectionV
{
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    //cell的内容大小
    layout.itemSize = CGSizeMake((self.view.frame.size.width - 100 )/ 3 , (self.view.frame.size.width - 100 )/ 3 );
    
    //上左下右
    layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    
    //cell的间距
    layout.minimumLineSpacing = 15;
    
    _fenleicolltion = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 49 ) collectionViewLayout:layout];
    _fenleicolltion.delegate = self;
    _fenleicolltion.dataSource = self;
    _fenleicolltion.backgroundColor = [UIColor whiteColor];
    _fenleicolltion.tag = 3000;
    _fenleicolltion.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);
    //整页翻动
    _fenleicolltion.pagingEnabled = YES;
    [self.view addSubview:_fenleicolltion];
    
    //注册重用池
    [_fenleicolltion registerClass:[VideoCollectionViewCell class] forCellWithReuseIdentifier:@"video"];
    [layout release];
    [_fenleicolltion release];

}
-(void)shipin
{
    self.arr = @[@"最新",@"囧镜头",@"最强王者",@"精彩击杀",@"新皮肤预告",@"起小点",@"徐老师",@"坑爹集锦",@"进击的小学生",@"暴走撸啊撸",@"联盟音乐会",@"三十六计",@"超神学院",@"全明星赛",@"Miss"];
    self.dataArr = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15"];
    self.shipinxqArr = @[@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=115&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1452928912&p_=29081&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=71&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453551824&p_=7817&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=224&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453551865&p_=7940&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=48&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453551883&p_=7994&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=199&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453551903&p_=8054&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=200&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453551926&p_=8123&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=204&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453551945&p_=8180&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=47&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453551965&p_=8240&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=85&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453551990&p_=8315&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=203&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453552010&p_=8375&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=167&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453552058&p_=8519&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=44&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453552080&p_=8585&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=45&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453552102&p_=8651&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=83&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453552122&p_=8711&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/apis/rest/ItemsService/videos?catwordid=110&page=1&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453552139&p_=8762&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol"];
    
    self.webArr = @[@"http://lol.zhangyoubao.com/mobiles/vlist/115?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619071&p_=29558&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/71?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619400&p_=30545&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/224?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619442&p_=30671&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/48?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619540&p_=30965&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/199?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619571&p_=31058&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/200?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619688&p_=31409&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/204?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619728&p_=31529&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/47?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619769&p_=31652&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/85?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619793&p_=31724&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/203?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619821&p_=31808&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/167?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619847&p_=31886&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/44?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619873&p_=31964&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/45?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619897&p_=32036&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/83?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619931&p_=32138&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol",@"http://lol.zhangyoubao.com/mobiles/vlist/110?dw=320&i_=583B56AA-D4B2-4B1E-B41B-D8388608FBE3&t_=1453619950&p_=32195&v_=40070204&d_=ios&osv_=9.2&version=0&a_=lol"];
    
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 15;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    VideoCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"video" forIndexPath:indexPath];
    cell.name.text = _arr[indexPath.row];
    cell.img.image =  [UIImage imageNamed:_dataArr[indexPath.row]];
    return cell;
}

//collection点击
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    VideoXiangqingViewController *videoVC = [[VideoXiangqingViewController alloc] init];
    videoVC.wangzhi = _shipinxqArr[indexPath.item];
    videoVC.title1 = _arr[indexPath.item];
    videoVC.tupian = _dataArr[indexPath.item];
    videoVC.webwangzhi = _webArr[indexPath.item];
    [self.navigationController pushViewController:videoVC animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
